home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / gg / gengetopt-2.6.lha / gengetopt-2.6 / src / parser.c < prev    next >
C/C++ Source or Header  |  2002-03-02  |  28KB  |  1,014 lines

  1.  
  2. /*  A Bison parser, made from parser.y
  3.     by GNU Bison version 1.28  */
  4.  
  5. #define YYBISON 1  /* Identify Bison output.  */
  6.  
  7. #define    TOK_PACKAGE    257
  8. #define    TOK_VERSION    258
  9. #define    TOK_OPTION    259
  10. #define    TOK_YES    260
  11. #define    TOK_NO    261
  12. #define    TOK_FLAG    262
  13. #define    TOK_PURPOSE    263
  14. #define    TOK_ONOFF    264
  15. #define    TOK_STRING    265
  16. #define    TOK_DEFAULT    266
  17. #define    TOK_MLSTRING    267
  18. #define    TOK_CHAR    268
  19. #define    TOK_ARGTYPE    269
  20.  
  21. #line 22 "parser.y"
  22.  
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <stdio.h>
  26.  
  27. #include "argsdef.h"
  28.  
  29. #include "gengetopt.h"
  30.  
  31. extern int gengetopt_count_line;
  32.  
  33. static int gengetopt_package_given = 0;
  34. static int gengetopt_version_given = 0;
  35. static int gengetopt_purpose_given = 0;
  36.  
  37. extern void yyerror ( char *error ) ;
  38. extern int yylex () ;
  39.  
  40. #define YYERROR_VERBOSE 1
  41. #define check_result \
  42.     if (o) { switch (o) { case 1: yyerror ("not enough memory"); break; case 2: yyerror ("long option redefined"); break; case 3: yyerror ("short option redefined"); break; case 4: yyerror ("bug found!!"); break; } YYERROR; }
  43.  
  44. #line 45 "parser.y"
  45. typedef union {
  46. char * str;
  47. char chr;
  48. int argtype;
  49. int bool;
  50. } YYSTYPE;
  51. #include <stdio.h>
  52.  
  53. #ifndef __cplusplus
  54. #ifndef __STDC__
  55. #define const
  56. #endif
  57. #endif
  58.  
  59.  
  60.  
  61. #define    YYFINAL        29
  62. #define    YYFLAG        -32768
  63. #define    YYNTBASE    17
  64.  
  65. #define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 23)
  66.  
  67. static const char yytranslate[] = {     0,
  68.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  69.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  70.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  71.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  72.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  73.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  74.     16,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  75.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
  94.      7,     8,     9,    10,    11,    12,    13,    14,    15
  95. };
  96.  
  97. #if YYDEBUG != 0
  98. static const short yyprhs[] = {     0,
  99.      0,     1,     4,     6,     8,    10,    12,    15,    18,    21,
  100.     24,    30,    37,    44,    52,    53
  101. };
  102.  
  103. static const short yyrhs[] = {    -1,
  104.     17,    21,     0,    11,     0,    13,     0,     6,     0,     7,
  105.      0,     3,    11,     0,     4,    11,     0,     9,    19,     0,
  106.      9,    18,     0,     5,    11,    14,    18,     7,     0,     5,
  107.     11,    14,    18,     8,    10,     0,     5,    11,    14,    18,
  108.     15,    20,     0,     5,    11,    14,    18,    15,    22,    20,
  109.      0,     0,    12,    16,    11,     0
  110. };
  111.  
  112. #endif
  113.  
  114. #if YYDEBUG != 0
  115. static const short yyrline[] = { 0,
  116.     74,    75,    79,    82,    86,    87,    91,    95,    98,   101,
  117.    103,   107,   111,   114,   131,   132
  118. };
  119. #endif
  120.  
  121.  
  122. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  123.  
  124. static const char * const yytname[] = {   "$","error","$undefined.","TOK_PACKAGE",
  125. "TOK_VERSION","TOK_OPTION","TOK_YES","TOK_NO","TOK_FLAG","TOK_PURPOSE","TOK_ONOFF",
  126. "TOK_STRING","TOK_DEFAULT","TOK_MLSTRING","TOK_CHAR","TOK_ARGTYPE","'='","input",
  127. "exp_str","exp_mlstr","exp_yesno","exp","def_value", NULL
  128. };
  129. #endif
  130.  
  131. static const short yyr1[] = {     0,
  132.     17,    17,    18,    19,    20,    20,    21,    21,    21,    21,
  133.     21,    21,    21,    21,    22,    22
  134. };
  135.  
  136. static const short yyr2[] = {     0,
  137.      0,     2,     1,     1,     1,     1,     2,     2,     2,     2,
  138.      5,     6,     6,     7,     0,     3
  139. };
  140.  
  141. static const short yydefact[] = {     1,
  142.      0,     0,     0,     0,     0,     2,     7,     8,     0,     3,
  143.      4,    10,     9,     0,     0,    11,     0,     0,    12,     5,
  144.      6,     0,    13,     0,     0,    14,    16,     0,     0
  145. };
  146.  
  147. static const short yydefgoto[] = {     1,
  148.     12,    13,    23,     6,    24
  149. };
  150.  
  151. static const short yypact[] = {-32768,
  152.      0,    -3,     1,     6,     2,-32768,-32768,-32768,     5,-32768,
  153. -32768,-32768,-32768,     7,    -1,-32768,    10,     4,-32768,-32768,
  154. -32768,     8,-32768,    -5,    11,-32768,-32768,    21,-32768
  155. };
  156.  
  157. static const short yypgoto[] = {-32768,
  158.      9,-32768,     3,-32768,-32768
  159. };
  160.  
  161.  
  162. #define    YYLAST        27
  163.  
  164.  
  165. static const short yytable[] = {    28,
  166.     20,    21,     2,     3,     4,    16,    17,     7,     5,    20,
  167.     21,     8,    10,    18,    11,    22,     9,    10,    14,    19,
  168.     29,    27,    15,    25,     0,     0,    26
  169. };
  170.  
  171. static const short yycheck[] = {     0,
  172.      6,     7,     3,     4,     5,     7,     8,    11,     9,     6,
  173.      7,    11,    11,    15,    13,    12,    11,    11,    14,    10,
  174.      0,    11,    14,    16,    -1,    -1,    24
  175. };
  176. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  177. #line 3 "/usr/lib/bison.simple"
  178. /* This file comes from bison-1.28.  */
  179.  
  180. /* Skeleton output parser for bison,
  181.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  182.  
  183.    This program is free software; you can redistribute it and/or modify
  184.    it under the terms of the GNU General Public License as published by
  185.    the Free Software Foundation; either version 2, or (at your option)
  186.    any later version.
  187.  
  188.    This program is distributed in the hope that it will be useful,
  189.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  190.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  191.    GNU General Public License for more details.
  192.  
  193.    You should have received a copy of the GNU General Public License
  194.    along with this program; if not, write to the Free Software
  195.    Foundation, Inc., 59 Temple Place - Suite 330,
  196.    Boston, MA 02111-1307, USA.  */
  197.  
  198. /* As a special exception, when this file is copied by Bison into a
  199.    Bison output file, you may use that output file without restriction.
  200.    This special exception was added by the Free Software Foundation
  201.    in version 1.24 of Bison.  */
  202.  
  203. /* This is the parser code that is written into each bison parser
  204.   when the %semantic_parser declaration is not specified in the grammar.
  205.   It was written by Richard Stallman by simplifying the hairy parser
  206.   used when %semantic_parser is specified.  */
  207.  
  208. #ifndef YYSTACK_USE_ALLOCA
  209. #ifdef alloca
  210. #define YYSTACK_USE_ALLOCA
  211. #else /* alloca not defined */
  212. #ifdef __GNUC__
  213. #define YYSTACK_USE_ALLOCA
  214. #define alloca __builtin_alloca
  215. #else /* not GNU C.  */
  216. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
  217. #define YYSTACK_USE_ALLOCA
  218. #include <alloca.h>
  219. #else /* not sparc */
  220. /* We think this test detects Watcom and Microsoft C.  */
  221. /* This used to test MSDOS, but that is a bad idea
  222.    since that symbol is in the user namespace.  */
  223. #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
  224. #if 0 /* No need for malloc.h, which pollutes the namespace;
  225.      instead, just don't use alloca.  */
  226. #include <malloc.h>
  227. #endif
  228. #else /* not MSDOS, or __TURBOC__ */
  229. #if defined(_AIX)
  230. /* I don't know what this was needed for, but it pollutes the namespace.
  231.    So I turned it off.   rms, 2 May 1997.  */
  232. /* #include <malloc.h>  */
  233.  #pragma alloca
  234. #define YYSTACK_USE_ALLOCA
  235. #else /* not MSDOS, or __TURBOC__, or _AIX */
  236. #if 0
  237. #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
  238.          and on HPUX 10.  Eventually we can turn this on.  */
  239. #define YYSTACK_USE_ALLOCA
  240. #define alloca __builtin_alloca
  241. #endif /* __hpux */
  242. #endif
  243. #endif /* not _AIX */
  244. #endif /* not MSDOS, or __TURBOC__ */
  245. #endif /* not sparc */
  246. #endif /* not GNU C */
  247. #endif /* alloca not defined */
  248. #endif /* YYSTACK_USE_ALLOCA not defined */
  249.  
  250. #ifdef YYSTACK_USE_ALLOCA
  251. #define YYSTACK_ALLOC alloca
  252. #else
  253. #define YYSTACK_ALLOC malloc
  254. #endif
  255.  
  256. /* Note: there must be only one dollar sign in this file.
  257.    It is replaced by the list of actions, each action
  258.    as one case of the switch.  */
  259.  
  260. #define yyerrok        (yyerrstatus = 0)
  261. #define yyclearin    (yychar = YYEMPTY)
  262. #define YYEMPTY        -2
  263. #define YYEOF        0
  264. #define YYACCEPT    goto yyacceptlab
  265. #define YYABORT     goto yyabortlab
  266. #define YYERROR        goto yyerrlab1
  267. /* Like YYERROR except do call yyerror.
  268.    This remains here temporarily to ease the
  269.    transition to the new meaning of YYERROR, for GCC.
  270.    Once GCC version 2 has supplanted version 1, this can go.  */
  271. #define YYFAIL        goto yyerrlab
  272. #define YYRECOVERING()  (!!yyerrstatus)
  273. #define YYBACKUP(token, value) \
  274. do                                \
  275.   if (yychar == YYEMPTY && yylen == 1)                \
  276.     { yychar = (token), yylval = (value);            \
  277.       yychar1 = YYTRANSLATE (yychar);                \
  278.       YYPOPSTACK;                        \
  279.       goto yybackup;                        \
  280.     }                                \
  281.   else                                \
  282.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  283. while (0)
  284.  
  285. #define YYTERROR    1
  286. #define YYERRCODE    256
  287.  
  288. #ifndef YYPURE
  289. #define YYLEX        yylex()
  290. #endif
  291.  
  292. #ifdef YYPURE
  293. #ifdef YYLSP_NEEDED
  294. #ifdef YYLEX_PARAM
  295. #define YYLEX        yylex(&yylval, &yylloc, YYLEX_PARAM)
  296. #else
  297. #define YYLEX        yylex(&yylval, &yylloc)
  298. #endif
  299. #else /* not YYLSP_NEEDED */
  300. #ifdef YYLEX_PARAM
  301. #define YYLEX        yylex(&yylval, YYLEX_PARAM)
  302. #else
  303. #define YYLEX        yylex(&yylval)
  304. #endif
  305. #endif /* not YYLSP_NEEDED */
  306. #endif
  307.  
  308. /* If nonreentrant, generate the variables here */
  309.  
  310. #ifndef YYPURE
  311.  
  312. int    yychar;            /*  the lookahead symbol        */
  313. YYSTYPE    yylval;            /*  the semantic value of the        */
  314.                 /*  lookahead symbol            */
  315.  
  316. #ifdef YYLSP_NEEDED
  317. YYLTYPE yylloc;            /*  location data for the lookahead    */
  318.                 /*  symbol                */
  319. #endif
  320.  
  321. int yynerrs;            /*  number of parse errors so far       */
  322. #endif  /* not YYPURE */
  323.  
  324. #if YYDEBUG != 0
  325. int yydebug;            /*  nonzero means print parse trace    */
  326. /* Since this is uninitialized, it does not stop multiple parsers
  327.    from coexisting.  */
  328. #endif
  329.  
  330. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  331.  
  332. #ifndef    YYINITDEPTH
  333. #define YYINITDEPTH 200
  334. #endif
  335.  
  336. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  337.     (effective only if the built-in stack extension method is used).  */
  338.  
  339. #if YYMAXDEPTH == 0
  340. #undef YYMAXDEPTH
  341. #endif
  342.  
  343. #ifndef YYMAXDEPTH
  344. #define YYMAXDEPTH 10000
  345. #endif
  346.  
  347. /* Define __yy_memcpy.  Note that the size argument
  348.    should be passed with type unsigned int, because that is what the non-GCC
  349.    definitions require.  With GCC, __builtin_memcpy takes an arg
  350.    of type size_t, but it can handle unsigned int.  */
  351.  
  352. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  353. #define __yy_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  354. #else                /* not GNU C or C++ */
  355. #ifndef __cplusplus
  356.  
  357. /* This is the most reliable way to avoid incompatibilities
  358.    in available built-in functions on various systems.  */
  359. static void
  360. __yy_memcpy (to, from, count)
  361.      char *to;
  362.      char *from;
  363.      unsigned int count;
  364. {
  365.   register char *f = from;
  366.   register char *t = to;
  367.   register int i = count;
  368.  
  369.   while (i-- > 0)
  370.     *t++ = *f++;
  371. }
  372.  
  373. #else /* __cplusplus */
  374.  
  375. /* This is the most reliable way to avoid incompatibilities
  376.    in available built-in functions on various systems.  */
  377. static void
  378. __yy_memcpy (char *to, char *from, unsigned int count)
  379. {
  380.   register char *t = to;
  381.   register char *f = from;
  382.   register int i = count;
  383.  
  384.   while (i-- > 0)
  385.     *t++ = *f++;
  386. }
  387.  
  388. #endif
  389. #endif
  390.  
  391. #line 217 "/usr/lib/bison.simple"
  392.  
  393. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  394.    into yyparse.  The argument should have type void *.
  395.    It should actually point to an object.
  396.    Grammar actions can access the variable by casting it
  397.    to the proper pointer type.  */
  398.  
  399. #ifdef YYPARSE_PARAM
  400. #ifdef __cplusplus
  401. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  402. #define YYPARSE_PARAM_DECL
  403. #else /* not __cplusplus */
  404. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  405. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  406. #endif /* not __cplusplus */
  407. #else /* not YYPARSE_PARAM */
  408. #define YYPARSE_PARAM_ARG
  409. #define YYPARSE_PARAM_DECL
  410. #endif /* not YYPARSE_PARAM */
  411.  
  412. /* Prevent warning if -Wstrict-prototypes.  */
  413. #ifdef __GNUC__
  414. #ifdef YYPARSE_PARAM
  415. int yyparse (void *);
  416. #else
  417. int yyparse (void);
  418. #endif
  419. #endif
  420.  
  421. int
  422. yyparse(YYPARSE_PARAM_ARG)
  423.      YYPARSE_PARAM_DECL
  424. {
  425.   register int yystate;
  426.   register int yyn;
  427.   register short *yyssp;
  428.   register YYSTYPE *yyvsp;
  429.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  430.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  431.  
  432.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  433.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  434.  
  435.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  436.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  437.  
  438. #ifdef YYLSP_NEEDED
  439.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  440.   YYLTYPE *yyls = yylsa;
  441.   YYLTYPE *yylsp;
  442.  
  443. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  444. #else
  445. #define YYPOPSTACK   (yyvsp--, yyssp--)
  446. #endif
  447.  
  448.   int yystacksize = YYINITDEPTH;
  449.   int yyfree_stacks = 0;
  450.  
  451. #ifdef YYPURE
  452.   int yychar;
  453.   YYSTYPE yylval;
  454.   int yynerrs;
  455. #ifdef YYLSP_NEEDED
  456.   YYLTYPE yylloc;
  457. #endif
  458. #endif
  459.  
  460.   YYSTYPE yyval;        /*  the variable used to return        */
  461.                 /*  semantic values from the action    */
  462.                 /*  routines                */
  463.  
  464.   int yylen;
  465.  
  466. #if YYDEBUG != 0
  467.   if (yydebug)
  468.     fprintf(stderr, "Starting parse\n");
  469. #endif
  470.  
  471.   yystate = 0;
  472.   yyerrstatus = 0;
  473.   yynerrs = 0;
  474.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  475.  
  476.   /* Initialize stack pointers.
  477.      Waste one element of value and location stack
  478.      so that they stay on the same level as the state stack.
  479.      The wasted elements are never initialized.  */
  480.  
  481.   yyssp = yyss - 1;
  482.   yyvsp = yyvs;
  483. #ifdef YYLSP_NEEDED
  484.   yylsp = yyls;
  485. #endif
  486.  
  487. /* Push a new state, which is found in  yystate  .  */
  488. /* In all cases, when you get here, the value and location stacks
  489.    have just been pushed. so pushing a state here evens the stacks.  */
  490. yynewstate:
  491.  
  492.   *++yyssp = yystate;
  493.  
  494.   if (yyssp >= yyss + yystacksize - 1)
  495.     {
  496.       /* Give user a chance to reallocate the stack */
  497.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  498.       YYSTYPE *yyvs1 = yyvs;
  499.       short *yyss1 = yyss;
  500. #ifdef YYLSP_NEEDED
  501.       YYLTYPE *yyls1 = yyls;
  502. #endif
  503.  
  504.       /* Get the current used size of the three stacks, in elements.  */
  505.       int size = yyssp - yyss + 1;
  506.  
  507. #ifdef yyoverflow
  508.       /* Each stack pointer address is followed by the size of
  509.      the data in use in that stack, in bytes.  */
  510. #ifdef YYLSP_NEEDED
  511.       /* This used to be a conditional around just the two extra args,
  512.      but that might be undefined if yyoverflow is a macro.  */
  513.       yyoverflow("parser stack overflow",
  514.          &yyss1, size * sizeof (*yyssp),
  515.          &yyvs1, size * sizeof (*yyvsp),
  516.          &yyls1, size * sizeof (*yylsp),
  517.          &yystacksize);
  518. #else
  519.       yyoverflow("parser stack overflow",
  520.          &yyss1, size * sizeof (*yyssp),
  521.          &yyvs1, size * sizeof (*yyvsp),
  522.          &yystacksize);
  523. #endif
  524.  
  525.       yyss = yyss1; yyvs = yyvs1;
  526. #ifdef YYLSP_NEEDED
  527.       yyls = yyls1;
  528. #endif
  529. #else /* no yyoverflow */
  530.       /* Extend the stack our own way.  */
  531.       if (yystacksize >= YYMAXDEPTH)
  532.     {
  533.       yyerror("parser stack overflow");
  534.       if (yyfree_stacks)
  535.         {
  536.           free (yyss);
  537.           free (yyvs);
  538. #ifdef YYLSP_NEEDED
  539.           free (yyls);
  540. #endif
  541.         }
  542.       return 2;
  543.     }
  544.       yystacksize *= 2;
  545.       if (yystacksize > YYMAXDEPTH)
  546.     yystacksize = YYMAXDEPTH;
  547. #ifndef YYSTACK_USE_ALLOCA
  548.       yyfree_stacks = 1;
  549. #endif
  550.       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
  551.       __yy_memcpy ((char *)yyss, (char *)yyss1,
  552.            size * (unsigned int) sizeof (*yyssp));
  553.       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
  554.       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
  555.            size * (unsigned int) sizeof (*yyvsp));
  556. #ifdef YYLSP_NEEDED
  557.       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
  558.       __yy_memcpy ((char *)yyls, (char *)yyls1,
  559.            size * (unsigned int) sizeof (*yylsp));
  560. #endif
  561. #endif /* no yyoverflow */
  562.  
  563.       yyssp = yyss + size - 1;
  564.       yyvsp = yyvs + size - 1;
  565. #ifdef YYLSP_NEEDED
  566.       yylsp = yyls + size - 1;
  567. #endif
  568.  
  569. #if YYDEBUG != 0
  570.       if (yydebug)
  571.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  572. #endif
  573.  
  574.       if (yyssp >= yyss + yystacksize - 1)
  575.     YYABORT;
  576.     }
  577.  
  578. #if YYDEBUG != 0
  579.   if (yydebug)
  580.     fprintf(stderr, "Entering state %d\n", yystate);
  581. #endif
  582.  
  583.   goto yybackup;
  584.  yybackup:
  585.  
  586. /* Do appropriate processing given the current state.  */
  587. /* Read a lookahead token if we need one and don't already have one.  */
  588. /* yyresume: */
  589.  
  590.   /* First try to decide what to do without reference to lookahead token.  */
  591.  
  592.   yyn = yypact[yystate];
  593.   if (yyn == YYFLAG)
  594.     goto yydefault;
  595.  
  596.   /* Not known => get a lookahead token if don't already have one.  */
  597.  
  598.   /* yychar is either YYEMPTY or YYEOF
  599.      or a valid token in external form.  */
  600.  
  601.   if (yychar == YYEMPTY)
  602.     {
  603. #if YYDEBUG != 0
  604.       if (yydebug)
  605.     fprintf(stderr, "Reading a token: ");
  606. #endif
  607.       yychar = YYLEX;
  608.     }
  609.  
  610.   /* Convert token to internal form (in yychar1) for indexing tables with */
  611.  
  612.   if (yychar <= 0)        /* This means end of input. */
  613.     {
  614.       yychar1 = 0;
  615.       yychar = YYEOF;        /* Don't call YYLEX any more */
  616.  
  617. #if YYDEBUG != 0
  618.       if (yydebug)
  619.     fprintf(stderr, "Now at end of input.\n");
  620. #endif
  621.     }
  622.   else
  623.     {
  624.       yychar1 = YYTRANSLATE(yychar);
  625.  
  626. #if YYDEBUG != 0
  627.       if (yydebug)
  628.     {
  629.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  630.       /* Give the individual parser a way to print the precise meaning
  631.          of a token, for further debugging info.  */
  632. #ifdef YYPRINT
  633.       YYPRINT (stderr, yychar, yylval);
  634. #endif
  635.       fprintf (stderr, ")\n");
  636.     }
  637. #endif
  638.     }
  639.  
  640.   yyn += yychar1;
  641.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  642.     goto yydefault;
  643.  
  644.   yyn = yytable[yyn];
  645.  
  646.   /* yyn is what to do for this token type in this state.
  647.      Negative => reduce, -yyn is rule number.
  648.      Positive => shift, yyn is new state.
  649.        New state is final state => don't bother to shift,
  650.        just return success.
  651.      0, or most negative number => error.  */
  652.  
  653.   if (yyn < 0)
  654.     {
  655.       if (yyn == YYFLAG)
  656.     goto yyerrlab;
  657.       yyn = -yyn;
  658.       goto yyreduce;
  659.     }
  660.   else if (yyn == 0)
  661.     goto yyerrlab;
  662.  
  663.   if (yyn == YYFINAL)
  664.     YYACCEPT;
  665.  
  666.   /* Shift the lookahead token.  */
  667.  
  668. #if YYDEBUG != 0
  669.   if (yydebug)
  670.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  671. #endif
  672.  
  673.   /* Discard the token being shifted unless it is eof.  */
  674.   if (yychar != YYEOF)
  675.     yychar = YYEMPTY;
  676.  
  677.   *++yyvsp = yylval;
  678. #ifdef YYLSP_NEEDED
  679.   *++yylsp = yylloc;
  680. #endif
  681.  
  682.   /* count tokens shifted since error; after three, turn off error status.  */
  683.   if (yyerrstatus) yyerrstatus--;
  684.  
  685.   yystate = yyn;
  686.   goto yynewstate;
  687.  
  688. /* Do the default action for the current state.  */
  689. yydefault:
  690.  
  691.   yyn = yydefact[yystate];
  692.   if (yyn == 0)
  693.     goto yyerrlab;
  694.  
  695. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  696. yyreduce:
  697.   yylen = yyr2[yyn];
  698.   if (yylen > 0)
  699.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  700.  
  701. #if YYDEBUG != 0
  702.   if (yydebug)
  703.     {
  704.       int i;
  705.  
  706.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  707.            yyn, yyrline[yyn]);
  708.  
  709.       /* Print the symbols being reduced, and their result.  */
  710.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  711.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  712.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  713.     }
  714. #endif
  715.  
  716.  
  717.   switch (yyn) {
  718.  
  719. case 3:
  720. #line 79 "parser.y"
  721. { yyval.str = yyvsp[0].str; ;
  722.     break;}
  723. case 4:
  724. #line 82 "parser.y"
  725. { yyval.str = yyvsp[0].str; ;
  726.     break;}
  727. case 5:
  728. #line 86 "parser.y"
  729. { yyval.bool = 1; ;
  730.     break;}
  731. case 6:
  732. #line 87 "parser.y"
  733. { yyval.bool = 0; ;
  734.     break;}
  735. case 7:
  736. #line 91 "parser.y"
  737. { if (gengetopt_package_given) { yyerror ("package redefined"); YYERROR; } else { gengetopt_package_given = 1; if (gengetopt_define_package (yyvsp[0].str)) { yyerror ("not enough memory"); YYERROR; } } ;
  738.     break;}
  739. case 8:
  740. #line 95 "parser.y"
  741. { if (gengetopt_version_given) { yyerror ("version redefined"); YYERROR; } else { gengetopt_version_given = 1; if (gengetopt_define_version (yyvsp[0].str)) { yyerror ("not enough memory"); YYERROR; } } ;
  742.     break;}
  743. case 9:
  744. #line 98 "parser.y"
  745. { if (gengetopt_purpose_given) { yyerror ("purpose redefined"); YYERROR; } else { gengetopt_purpose_given = 1; if (gengetopt_define_purpose (yyvsp[0].str)) { yyerror ("not enough memory"); YYERROR; } } ;
  746.     break;}
  747. case 10:
  748. #line 101 "parser.y"
  749. { if (gengetopt_purpose_given) { yyerror ("purpose redefined"); YYERROR; } else { gengetopt_purpose_given = 1; if (gengetopt_define_purpose (yyvsp[0].str)) { yyerror ("not enough memory"); YYERROR; } } ;
  750.     break;}
  751. case 11:
  752. #line 103 "parser.y"
  753. { int o = gengetopt_add_option (yyvsp[-3].str, yyvsp[-2].chr, yyvsp[-1].str, ARG_NO, 0, 0, 0); check_result; ;
  754.     break;}
  755. case 12:
  756. #line 107 "parser.y"
  757. { int o = gengetopt_add_option (yyvsp[-4].str, yyvsp[-3].chr, yyvsp[-2].str, ARG_FLAG, yyvsp[0].bool, 0, 0); check_result; ;
  758.     break;}
  759. case 13:
  760. #line 111 "parser.y"
  761. { int o = gengetopt_add_option (yyvsp[-4].str, yyvsp[-3].chr, yyvsp[-2].str, yyvsp[-1].argtype, 0, yyvsp[0].bool, 0); check_result; ;
  762.     break;}
  763. case 14:
  764. #line 115 "parser.y"
  765.   int o = gengetopt_add_option (yyvsp[-5].str, yyvsp[-4].chr, yyvsp[-3].str, yyvsp[-2].argtype, 0, yyvsp[0].bool, yyvsp[-1].str); 
  766.   check_result; 
  767.   if (yyvsp[-1].str != 0 && 
  768.       (yyvsp[-2].argtype == ARG_FLOAT || yyvsp[-2].argtype == ARG_DOUBLE || yyvsp[-2].argtype == ARG_LONGDOUBLE))
  769.     {
  770.       fprintf 
  771.         (stderr, 
  772.          "gengetopt: %d: Warning: default values may not work correctly with "
  773.          "type %s\n", gengetopt_count_line, arg_names [yyvsp[-2].argtype]);
  774.       fprintf
  775.         (stderr, "This problem will be fixed in future releases.\n");
  776.     }
  777. ;
  778.     break;}
  779. case 15:
  780. #line 131 "parser.y"
  781. { yyval.str = 0; ;
  782.     break;}
  783. case 16:
  784. #line 132 "parser.y"
  785. { yyval.str = yyvsp[0].str; ;
  786.     break;}
  787. }
  788.    /* the action file gets copied in in place of this dollarsign */
  789. #line 543 "/usr/lib/bison.simple"
  790.  
  791.   yyvsp -= yylen;
  792.   yyssp -= yylen;
  793. #ifdef YYLSP_NEEDED
  794.   yylsp -= yylen;
  795. #endif
  796.  
  797. #if YYDEBUG != 0
  798.   if (yydebug)
  799.     {
  800.       short *ssp1 = yyss - 1;
  801.       fprintf (stderr, "state stack now");
  802.       while (ssp1 != yyssp)
  803.     fprintf (stderr, " %d", *++ssp1);
  804.       fprintf (stderr, "\n");
  805.     }
  806. #endif
  807.  
  808.   *++yyvsp = yyval;
  809.  
  810. #ifdef YYLSP_NEEDED
  811.   yylsp++;
  812.   if (yylen == 0)
  813.     {
  814.       yylsp->first_line = yylloc.first_line;
  815.       yylsp->first_column = yylloc.first_column;
  816.       yylsp->last_line = (yylsp-1)->last_line;
  817.       yylsp->last_column = (yylsp-1)->last_column;
  818.       yylsp->text = 0;
  819.     }
  820.   else
  821.     {
  822.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  823.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  824.     }
  825. #endif
  826.  
  827.   /* Now "shift" the result of the reduction.
  828.      Determine what state that goes to,
  829.      based on the state we popped back to
  830.      and the rule number reduced by.  */
  831.  
  832.   yyn = yyr1[yyn];
  833.  
  834.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  835.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  836.     yystate = yytable[yystate];
  837.   else
  838.     yystate = yydefgoto[yyn - YYNTBASE];
  839.  
  840.   goto yynewstate;
  841.  
  842. yyerrlab:   /* here on detecting error */
  843.  
  844.   if (! yyerrstatus)
  845.     /* If not already recovering from an error, report this error.  */
  846.     {
  847.       ++yynerrs;
  848.  
  849. #ifdef YYERROR_VERBOSE
  850.       yyn = yypact[yystate];
  851.  
  852.       if (yyn > YYFLAG && yyn < YYLAST)
  853.     {
  854.       int size = 0;
  855.       char *msg;
  856.       int x, count;
  857.  
  858.       count = 0;
  859.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  860.       for (x = (yyn < 0 ? -yyn : 0);
  861.            x < (sizeof(yytname) / sizeof(char *)); x++)
  862.         if (yycheck[x + yyn] == x)
  863.           size += strlen(yytname[x]) + 15, count++;
  864.       msg = (char *) malloc(size + 15);
  865.       if (msg != 0)
  866.         {
  867.           strcpy(msg, "parse error");
  868.  
  869.           if (count < 5)
  870.         {
  871.           count = 0;
  872.           for (x = (yyn < 0 ? -yyn : 0);
  873.                x < (sizeof(yytname) / sizeof(char *)); x++)
  874.             if (yycheck[x + yyn] == x)
  875.               {
  876.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  877.             strcat(msg, yytname[x]);
  878.             strcat(msg, "'");
  879.             count++;
  880.               }
  881.         }
  882.           yyerror(msg);
  883.           free(msg);
  884.         }
  885.       else
  886.         yyerror ("parse error; also virtual memory exceeded");
  887.     }
  888.       else
  889. #endif /* YYERROR_VERBOSE */
  890.     yyerror("parse error");
  891.     }
  892.  
  893.   goto yyerrlab1;
  894. yyerrlab1:   /* here on error raised explicitly by an action */
  895.  
  896.   if (yyerrstatus == 3)
  897.     {
  898.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  899.  
  900.       /* return failure if at end of input */
  901.       if (yychar == YYEOF)
  902.     YYABORT;
  903.  
  904. #if YYDEBUG != 0
  905.       if (yydebug)
  906.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  907. #endif
  908.  
  909.       yychar = YYEMPTY;
  910.     }
  911.  
  912.   /* Else will try to reuse lookahead token
  913.      after shifting the error token.  */
  914.  
  915.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  916.  
  917.   goto yyerrhandle;
  918.  
  919. yyerrdefault:  /* current state does not do anything special for the error token. */
  920.  
  921. #if 0
  922.   /* This is wrong; only states that explicitly want error tokens
  923.      should shift them.  */
  924.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  925.   if (yyn) goto yydefault;
  926. #endif
  927.  
  928. yyerrpop:   /* pop the current state because it cannot handle the error token */
  929.  
  930.   if (yyssp == yyss) YYABORT;
  931.   yyvsp--;
  932.   yystate = *--yyssp;
  933. #ifdef YYLSP_NEEDED
  934.   yylsp--;
  935. #endif
  936.  
  937. #if YYDEBUG != 0
  938.   if (yydebug)
  939.     {
  940.       short *ssp1 = yyss - 1;
  941.       fprintf (stderr, "Error: state stack now");
  942.       while (ssp1 != yyssp)
  943.     fprintf (stderr, " %d", *++ssp1);
  944.       fprintf (stderr, "\n");
  945.     }
  946. #endif
  947.  
  948. yyerrhandle:
  949.  
  950.   yyn = yypact[yystate];
  951.   if (yyn == YYFLAG)
  952.     goto yyerrdefault;
  953.  
  954.   yyn += YYTERROR;
  955.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  956.     goto yyerrdefault;
  957.  
  958.   yyn = yytable[yyn];
  959.   if (yyn < 0)
  960.     {
  961.       if (yyn == YYFLAG)
  962.     goto yyerrpop;
  963.       yyn = -yyn;
  964.       goto yyreduce;
  965.     }
  966.   else if (yyn == 0)
  967.     goto yyerrpop;
  968.  
  969.   if (yyn == YYFINAL)
  970.     YYACCEPT;
  971.  
  972. #if YYDEBUG != 0
  973.   if (yydebug)
  974.     fprintf(stderr, "Shifting error token, ");
  975. #endif
  976.  
  977.   *++yyvsp = yylval;
  978. #ifdef YYLSP_NEEDED
  979.   *++yylsp = yylloc;
  980. #endif
  981.  
  982.   yystate = yyn;
  983.   goto yynewstate;
  984.  
  985.  yyacceptlab:
  986.   /* YYACCEPT comes here.  */
  987.   if (yyfree_stacks)
  988.     {
  989.       free (yyss);
  990.       free (yyvs);
  991. #ifdef YYLSP_NEEDED
  992.       free (yyls);
  993. #endif
  994.     }
  995.   return 0;
  996.  
  997.  yyabortlab:
  998.   /* YYABORT comes here.  */
  999.   if (yyfree_stacks)
  1000.     {
  1001.       free (yyss);
  1002.       free (yyvs);
  1003. #ifdef YYLSP_NEEDED
  1004.       free (yyls);
  1005. #endif
  1006.     }
  1007.   return 1;
  1008. }
  1009. #line 135 "parser.y"
  1010.  
  1011.  
  1012.  
  1013.